package com.waymap.utils.mq;


import com.waymap.common.Constant;
import com.waymap.domain.Accounts;
import com.waymap.service.SyncService;
import com.waymap.service.TransactionInventoryDetailsService;
import com.waymap.service.TransactionsService;
import com.waymap.utils.NSRestConnector;
import com.waymap.utils.StringUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.reflections.util.Utils;
import org.scribe.model.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by tim on 2018/7/27.
 * 消费者
 * @Author alfred
 */
@Component
public class InvertoryConsumer {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private TransactionInventoryDetailsService transactionInventoryDetailsService;


    @JmsListener(destination = "syncInventoryQueue", containerFactory = "jmsQueueListener")
    public void syncInventoryqueue(TextMessage messageText) throws JMSException {
        logger.info("Consumer收到的报文为:" + messageText.getText().toString());
        messageText.acknowledge();//消息确认
        transactionInventoryDetailsService.syncDataFromNS(messageText.getText().toString());
    }

}
